import { getData, postData, putData, deleteData } from '@/api/common/index';

const baseUserCommissionWithdrawal = '/api/user-commission-withdrawal';

const UserCommissionWithdrawalUrl = {
	page: '/page',
	url: '',
	submitUserCommissionWithdrawal: '/submitUserCommissionWithdrawal',
	exportInfo: '/export',
};

export function getUserCommissionWithdrawalPage(
	params: any,
	pageNo: number | null | undefined,
	pageSize: number | null | undefined,
): Promise<any> {
	let url =
		baseUserCommissionWithdrawal +
		UserCommissionWithdrawalUrl.page +
		'?pageNum=' +
		(pageNo ? pageNo : 1) +
		'&pageSize=' +
		(pageSize ? pageSize : 10);
	return postData(url, params);
}

export function getUserCommissionWithdrawalDetail(id: number): Promise<any> {
	return getData(
		baseUserCommissionWithdrawal +
			UserCommissionWithdrawalUrl.url +
			'?id=' +
			id,
	);
}

export function deleteUserCommissionWithdrawal(ids: string): Promise<any> {
	return deleteData(
		baseUserCommissionWithdrawal +
			UserCommissionWithdrawalUrl.url +
			'?ids=' +
			ids,
	);
}

export function submitUserCommissionWithdrawal(id: number): Promise<any> {
	return getData(
		baseUserCommissionWithdrawal +
			UserCommissionWithdrawalUrl.submitUserCommissionWithdrawal +
			'?id=' +
			id,
	);
}

export function addOrEditUserCommissionWithdrawal(
	method: string,
	params: any,
): Promise<any> {
	if ('put' == method) {
		return putData(
			baseUserCommissionWithdrawal + UserCommissionWithdrawalUrl.url,
			params,
		);
	} else {
		return postData(
			baseUserCommissionWithdrawal + UserCommissionWithdrawalUrl.url,
			params,
		);
	}
}

export function exportUserCommissionWithdrawal(
	params: any,
	response: any,
): Promise<any> {
	const url =
		baseUserCommissionWithdrawal + UserCommissionWithdrawalUrl.exportInfo;
	return postData(url, params, response);
}
